<?php

include './config.php';
include './include/weibosae.php';

$mc_key = 'list';
$mc = memcache_init();
$mc && $result = memcache_get($mc, $mc_key);

if($result === false)
{
	$wb_base = new cls_weibosae(WB_AKEY);
	$wb_base->setUser(WB_USERNAME, WB_PASSWORD);

	$i=0;
	$result = array();
	foreach($wb_base->mentions(50) as $value)
	{
		if($i >= 20)
		{
			break;
		}

		if(preg_match('/^我通过\s*@互粉查询\s*计算出我的微博的互粉率是\s*(\d+)%，([^\s]+)\s*你也来看看你的互粉率吧！/s', $value['text'], $data))
		{
			if($data[1] < 0 || $data[1] > 100)
			{
				continue;
			}
			$result[$i++] = array(
				'value'		=> $data[1],
				'tips'		=> $data[2],
				'uid'		=> $value['user']['id'],
				'nick'		=> $value['user']['domain'],
				'img'		=> $value['user']['profile_image_url'],
				'fans'		=> $value['user']['followers_count'],
				'friends'	=> $value['user']['friends_count'],
			);
		}
	}
	
	memcache_set($mc, $mc_key, $result, null, 300);
}

print_r($result);






